#include <iostream>

using namespace std;

void printArray(const int [], int);

int main()
{

  int myArray[5] = {1, 2, 3, 4, 5};

  printArray(myArray, 5);

  return 0;
}

void printArray(const int array[], int size)
{
  for(int i = 0; i < size; i++)
  {
    cout << "array[" << i << "] = " << array[i]++ << endl;
  }
}

/*Compiling error
 * yujiehao@Eugene-1:~/works/c_c++_projects/introduction-to-programming-with-cpp/chap_7_array_single_dimensional/7.5_passing_arrays_to_functions$
 * g++ Listing_7.5_ConstArrayDemo.cpp -o Listing_7.5_ConstArrayDemo
 * Listing_7.5_ConstArrayDemo.cpp: In function ‘void printArray(const int*,
 * int)’:
 * Listing_7.5_ConstArrayDemo.cpp:21:48: error: increment of read-only
 * location ‘*(array + ((sizetype)(((long unsigned int)i) * 4ul)))’
 *      cout << "array[" << i << "] = " << array[i]++ << endl;
 */
